dofile("StylusBox2.lua")
dofile("libColor.lua")

ProgressBar = {
	new = function (scr, x, y, w, h, val, way, color)
		local x2 = x+w
		local y2 = y+h
		
		local maxVal = 100
		local minVal = 0
		
		if way == nil then
			way = 1
		end
		
		if color == nil then
			color = c_green
		end
		
		local draw = function (self)
			screen.drawGradientRect(scr, x, y, x2, y2, c_lightgrey, c_lightgrey, c_white, c_white)
			
			if way == 1 then
				screen.drawGradientRect(scr, x, y, (x+(val*(w/100))), y2, c_white, c_white, color, color)
			elseif way == 2 then
				screen.drawGradientRect(scr, x2, y, (x2-(val*(w/100))), y2, c_white, c_white, color, color)
			elseif way == 3 then
				screen.drawGradientRect(scr, x, y, x2, (y+(val*(h/100))), c_white, c_white, color, color)
			elseif way == 4 then
				screen.drawGradientRect(scr, x, (y2-(val*(h/100))), x2, y2, c_white, c_white, color, color)
			end
			
			if val >= maxVal then
				val = maxVal
			elseif val <= minVal then
				val = minVal
			end
		end
		
		local incValue = function (self, incVal)
			val = val+incVal
		end
		
		local decValue = function (self, decVal)
			val = val-decVal
		end
		
		local getValue = function (self)
			return val
		end
		
		local getMaxValue = function (self)
			return maxVal
		end
		
		local getMinValue = function (self)
			return minVal
		end
		
		local clear = function (self)
			self = nil
		end
		
		return {
			draw = draw,
			incValue = incValue,
			decValue = decValue,
			getValue = getValue,
			getMaxValue = getMaxValue,
			getMinValue = getMinValue,
			clear = clear
		}
	end
}